package com.zh.work.service.platform.branch.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zh.work.dao.platform.branch.BranchHelpMapper;
import com.zh.work.entity.branch.BranchHelpEntity;
import com.zh.work.entity.branch.BranchSpreadEntity;
import com.zh.work.service.platform.branch.BranchHelpService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @Description: 机构文档管理设置业务逻辑实现层
 * @Author: Li.HuiNeng
 * @Create in: 2019/10/31
 * @Version: 1.0.1
 */
@Service
public class BranchHelpServiceImpl extends ServiceImpl<BranchHelpMapper, BranchHelpEntity> implements BranchHelpService {

    @Autowired
    private BranchHelpMapper branchHelpMapper;


    @Override
    public IPage<BranchHelpEntity> selectPage(IPage<BranchHelpEntity> page, BranchHelpEntity helpEntity) {
        return branchHelpMapper.selectPage(page, new LambdaQueryWrapper<BranchHelpEntity>()
                .like(StringUtils.isNotEmpty(helpEntity.getBranchNo()), BranchHelpEntity::getBranchNo, helpEntity.getBranchNo())
                .like(StringUtils.isNotEmpty(helpEntity.getKeyVal()), BranchHelpEntity::getKeyVal, helpEntity.getKeyVal())
                .like(StringUtils.isNotEmpty(helpEntity.getTitle()), BranchHelpEntity::getTitle, helpEntity.getTitle())
        );
    }

    /**
     * ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
     * ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓        文案营销接口     ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
     */

    @Override
    public IPage<BranchSpreadEntity> selectPagesSpread(Page<BranchSpreadEntity> page, BranchSpreadEntity branchSpreadEntity) {
        return branchHelpMapper.selectPagesSpread(page, branchSpreadEntity.getTitle(), branchSpreadEntity.getKeyVal(), branchSpreadEntity.getBranchNo());
    }

    @Override
    public int addSpread(BranchSpreadEntity branchSpreadEntity) { return branchHelpMapper.addSpread(branchSpreadEntity); }

    @Override
    public int deleteBranchSpreadById(Long id) { return branchHelpMapper.deleteBranchSpreadById(id); }

    @Override
    public int deleteBranchSpreadBatchByIds(List<Integer> ids) { return branchHelpMapper.deleteBranchSpreadBatchByIds(ids); }

    @Override
    public int updateBranchSpreadById(BranchSpreadEntity spread) { return branchHelpMapper.updateBranchSpreadById(spread); }
}
